package com.lhc.nacosconsumer.controller;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.lhc.nacosconsumer.repository.ProviderFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName ConsumerController
 * @Description:
 * @Author: asus
 * @CreateDate: 2020-11-24 11:07
 * @UpdateUser: asus
 * @UpdateDate: 2020-11-24 11:07
 * @UpdateRemark:
 * @Version: 1.0
 */
@RestController
@RefreshScope
public class ConsumerController {

    @Autowired
    private ProviderFeign providerFeign;
    @Value("${spring.application.name}")
    String name;
    //nacos配置文件属性：sleep = 3000
    @Value("${sleep}")
    String sleep;
    //nacos配置文件属性： timeout = 5000
    @Value("${timeout}")
    String time;

    @RequestMapping("hi")
    public String hi() {
        return this.providerFeign.hello();
    }

    @RequestMapping("index")
    public String index (){
        return "这是Index；";
    }

    @RequestMapping("/config")
    public List config(){
        try {
            Thread.sleep(Long.parseLong(sleep));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        List list = new ArrayList();
        list.add(name);
        list.add(sleep);
        list.add(time);
        return list;
    }


}